import { defineConfig } from "vite";
import vue from "@vitejs/plugin-vue";
import Components from "unplugin-vue-components/vite";
import AutoImport from "unplugin-auto-import/vite";
import path from "path";
// https://vitejs.dev/config/
export default defineConfig({
   plugins: [
      vue(),
      Components(),
      AutoImport({
         imports: ["vue", "vue-router"], // 自动导入 Vue 和 Vue Router 的函数
         dts: "./auto-imports.d.ts", // 生成对应的 .d.ts 文件
      }),
   ],
   server: {
      port: 3000,
      // 跨域代理
      proxy: {
         "/admin": {
            target: "http://192.168.0.23",
            changeOrigin: true,
            rewrite: (path) => {
               return path;
            },
         }
      },
   },
   resolve: {
      alias: {
         "@": path.resolve(__dirname, "src"),
         "@api": path.resolve(__dirname, "src/api"),
      },
   },
});
